cmake_minimum_required(VERSION 3.14)
project(reflector_slam_system)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(PCL REQUIRED COMPONENTS common io)
find_package(pcl_conversions REQUIRED)
find_package(cartographer_ros REQUIRED)
find_package(cartographer_ros_msgs REQUIRED)
find_package(cartographer REQUIRED)
find_package(Ceres REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(PCL REQUIRED COMPONENTS common io filters search segmentation)

include_directories(
  include/reflector_detector
  ${PCL_INCLUDE_DIRS}
  ${EIGEN3_INCLUDE_DIR}
)

add_definitions(${PCL_DEFINITIONS})

########################################################################
# 可执行节点（单节点多文件）
add_executable(reflector_detector_node
  src/reflector_detector_node.cpp
  src/reflector_detector.cpp        # 直接集成原实现（函数名保持）
)

ament_target_dependencies(reflector_detector_node
  geometry_msgs
  rclcpp 
  sensor_msgs 
  nav_msgs 
  visualization_msgs 
  tf2 
  tf2_ros 
  tf2_geometry_msgs 
  pcl_conversions
  cartographer_ros
  cartographer_ros_msgs
  Ceres 
)

target_link_libraries(reflector_detector_node ${PCL_LIBRARIES} ${CERES_LIBRARIES})
target_include_directories(reflector_detector_node PRIVATE ${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})

########################################################################
# add_executable(reflector_locator_node
#   src/reflector_locator_node.cpp
#   src/reflector_locator.cpp        # 直接集成原实现（函数名保持）
# )

add_executable(cloud_stamp_fix_node src/cloud_stamp_fix_node.cpp)
ament_target_dependencies(cloud_stamp_fix_node rclcpp sensor_msgs)
install(TARGETS cloud_stamp_fix_node DESTINATION lib/${PROJECT_NAME})


########################################################################
install(TARGETS reflector_detector_node
  RUNTIME DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY include/
  DESTINATION include
)

install(DIRECTORY launch config
  DESTINATION share/${PROJECT_NAME}
)

ament_package()
